package com.pliu.client;

import com.pliu.concreteHandler.Boss;
import com.pliu.concreteHandler.CTO;
import com.pliu.concreteHandler.ProjectManager;
import com.pliu.handler.Handler;
import com.pliu.request.Request;

/**
 * 创建处理链，并向链头的具体处理者对象提交请求
 **/
public class Client {

    /**
     * 创建处理链
     * @return 链头的具体处理者
     */
    private static Handler getChain(){

        ProjectManager projectManager = new ProjectManager(2);
        CTO cto = new CTO(5);
        Boss boss = new Boss(Integer.MAX_VALUE);

        // 设置下一级
        projectManager.setNextHandler(cto);
        cto.setNextHandler(boss);

        return projectManager;
    }

    public static void main(String[] args) {
        Handler chain = getChain();
        System.out.println("============================");
        chain.handleRequest(new Request(1,"张三"));
        System.out.println("============================");
        chain.handleRequest(new Request(3,"李四"));
        System.out.println("============================");
        chain.handleRequest(new Request(111,"王五"));
        System.out.println("============================");
    }

}
